#include <bits/stdc++.h>
using namespace std;
int a[1005];
int main(){
    cin >> a[1] >> a[2];
    int sum = a[1] + a[2];
    int m, n;
    cin >> m >> n;
    for (int i = 3; i <= n; i++){
        a[i] = a[i - 1] + a[i - 2];
        sum += a[i];
        if (a[i] >= m) break;
    }
    cout << sum;
    return 0;
}